// require([
//     'config',
//     'axios',
//     'jquery',
// 	'ApiClient',
// 	'jquery.cookie'
// ], function (config, axios, $, ApiClient) {
    // 页面高度
    $(function(){
        var window_height = $(window).height();
        var window_width = $(window).width();
        var head_height = $(".head .test").height();
        var foot_height = $(".foot").height();
    //     var head_height = $('.body .head').height();
    //     alert(window_height+head_height);
    //     $(".body").css('height',window_height-head_height+'px');
        // if(window_width<1200){
        //     alert(1);
        // }
        $("body .body").css('height',window_height-head_height-foot_height);
        $(".dock-item img").each(function(){
            $(this).hover(function(){
                $(this).css('width','130%');
                // $(this).css('transform','scale(1.5,1.5)');
                // $(this).animate({'top':'-20px'});
                // $(".dock-item span").css('margin-bottom','10px');
            },function(){
                $(this).css('width','100%');
                // $(this).css('transform','scale(1,1)');
                // $(".dock-item span").css('margin-bottom','');
                // $(this).animate({'top':0});
            });
        });
    });
    // 登录人员信息
    $(function(){
        $(".head .img i").click(function(){
            $(".head .head_user").toggle();
        });
        $(".head .head_user .head_user_flace").click(function(){
            $(".head .head_user").hide();
        });
    });

    // 子系统隐藏显示
    $(function(){
        var lastX = 0;
        $(".body .body-left").mousedown(function() {
            var flag = false;
            var stop;
            stop = setTimeout(function() {//down 1s，才运行。
                flag = true;
                console.log("开始处理你的代码.");
                $(".body .body-left").mousemove(function(e) {
                    if (lastX > e.pageX) {
                        $(this).hide(1000);
                        $(".body .body-left").unbind('mousemove');
                        // $(".body .body-left").css("width","0%");
                        trigger = setTimeout(function(){
                            $(".body .body-right").css("width","99.8%");
                        },1000);  
                        // $("#dirSpan").text("←");
                    }
                    lastX = e.pageX;
                });
            }, 1000);
            $(".body .body-left").mouseup(function() {//鼠标up时，判断down了多久，不足一秒，不执行down的代码。
                if (!flag) {
                    clearTimeout(stop);
                }
            });
        });
        $(".body .body-right").mousedown(function() {
            var flag = false;
            var stop;
            stop = setTimeout(function() {//down 1s，才运行。
                flag = true;
                console.log("开始处理你的代码.");
                $(".body .body-right").mousemove(function(e) {
                    if (lastX < e.pageX) {
                        $(".body .body-left").show(1000);
                        $(".body .body-right").unbind('mousemove');
                        $(".body .body-right").css("width","89.8%").show(1000);
                        
                        // $(".body .body-left").css("width","10%");
                        // $("#dirSpan").text("→");
                    }
                    lastX = e.pageX;
                });
            }, 1000);
            $(".body .body-right").mouseup(function() {//鼠标up时，判断down了多久，不足一秒，不执行down的代码。
                if (!flag) {
                    clearTimeout(stop);
                }
            });
        });

    });

    // 子系统介绍框
    // $(function(){
    //     $(".body .body-left .ZXT-button").each(function(){
    //         $(this).hover(function(){
    //             var JSKGDS = "";
    //             var head = $(".head").height();
    //             JSKGDS = $(this).offset().top-head;
    //             $(".body .body-right .WZ-JSK img").show(1000);
    //             $(".body .body-right .WZ-JSK img").animate({top:JSKGDS+'px'});
    //         });

    //     });
    //     $(".body .body-left").hover(function(){},function(){
    //         $(".body .body-right .WZ-JSK img").hide(1000);
    //     });
    // });

    // 子系统toggle
    $(function(){
        var window_height = $(window).height();
        var head_height = $('.head .test').height();
        $(".body .body-left-toggle").css('height',$(".body-right").height()+'px');
        $(".body .body-left-toggle").css('line-height',$(".body-right").height()+'px');
        $(".body .body-left-toggle").css('top',head_height+'px');
        $(".body .body-left-show").click(function(){
            $(".body .body-left-hide").show();
            $(this).hide();
            $(".body .body-left").show();
            $(".body-right").css('width','89.6%');
        });
        $(".body .body-left-hide").click(function(){
            $(".body .body-left-show").show();
            $(this).hide();
            $(".body .body-left").hide();
             $(".body-right").css('width','100%');
        });
        function index(){
            $('.body .body-left-toggle i').css('color','#03a9f4');  //默认值
            setTimeout(" $('.body .body-left-toggle i').css('color','#fF0000')",100); //第一次闪烁
            setTimeout( "$('.body .body-left-toggle i').css('color','#ccc')",200); //第二次闪烁
        };
        window.setInterval(index,500); //让index 多久循环一次 

    });

    // 展示页面
    $(function(){
        var window_height = $(window).height();
        var window_width = $(window).width();
        $(".card-area .card-item p").hide();
        $(".card-area .card-item.active p").show();
        $(".card-area .card-item .card .card-title .content").css("bottom","22");
        $(".card-area .card-item.active .card .card-title .content").css("botton","-2");
        // 标题文字大小
        $(".card-area .card-item .card .card-title h1").css('font-size','12px');
        $(".card-area .card-item.active .card .card-title h1").css('font-size','15px');
        if(window_width<1600){
            $(".card-area .card-item .card .card-title .zq-product-img").css('width','30px');
            $(".card-area .card-item .card .card-title .zq-product-img").css('height','30px');
            $(".card-area .card-item.active .card .card-title .zq-product-img").css('width','40px');
            $(".card-area .card-item.active .card .card-title .zq-product-img").css('height','40px');
            $(".card-area .card-item .card .card-title .zq-product-img").css('line-height','28px');
            $(".card-area .card-item.active .card .card-title .zq-product-img").css('line-height','38px');
            // $(".card-area .card-item .card .card-title .zq-product-img").css('boder',0);
            // $(".card-area .card-item.active .card .card-title .zq-product-img").css('boder','2px solid #fff');
        }
        $(".card-area .card-item").hover(function(){
            $(".card-area .card-item p").hide();
            $(".card-area .card-item.active p").show();
            $(".card-area .card-item .card .card-title h1").css('font-size','12px');
            $(".card-area .card-item.active .card .card-title h1").css('font-size','16px');
            if(window_width<1600){
                $(".card-area .card-item .card .card-title .zq-product-img").css('width','30px');
                $(".card-area .card-item .card .card-title .zq-product-img").css('height','30px');
                $(".card-area .card-item.active .card .card-title .zq-product-img").css('width','40px');
                $(".card-area .card-item.active .card .card-title .zq-product-img").css('height','40px');
                $(".card-area .card-item .card .card-title .zq-product-img").css('line-height','28px');
                $(".card-area .card-item.active .card .card-title .zq-product-img").css('line-height','38px');
                // $(".card-area .card-item .card .card-title .zq-product-img").css('boder',0);
                // $(".card-area .card-item.active .card .card-title .zq-product-img").css('boder','2px solid #fff');
            }
        });
    });

    $(function(){
        var R_ZSCD = '<div class="R_ZSS ZS0"><i class="fa fa-share-alt" aria-hidden="true"></i><span>生态地面监测1</span></div>'
                    +'<div class="R_ZSS ZS1"><i class="fa fa-pie-chart" aria-hidden="true"></i><span>遥感监测管理2</span></div>'
                    +'<div class="R_ZSS ZS2"><i class="fa fa-snowflake-o" aria-hidden="true"></i><span>自然保护区管理3</span></div>'
                    +'<div class="R_ZSS ZS3"><i class="fa fa-viadeo" aria-hidden="true"></i><span>生物多样性4</span></div>'
                    +'<div class="R_ZSS ZS4"><i class="fa fa-american-sign-language-interpreting" aria-hidden="true"></i><span>县域考核5</span></div>'
                    +'<div class="R_ZSS ZS5"><i class="fa fa-star-half-o" aria-hidden="true"></i><span>生态红线6</span></div>'
                    +'<div> </div>'
                    +'<div> </div>'
                    +'<div> </div>'
                    +'<div> </div>'
                    +'<div> </div>'
                    +'<div> </div>'
        var L_ZSCD = '<div class="L_ZSS ZS0"><i class="fa fa-star-half-o" aria-hidden="true"></i><span>生态红线6</span></div>'
                    +'<div class="L_ZSS ZS1"><i class="fa fa-american-sign-language-interpreting" aria-hidden="true"></i><span>县域考核5</span></div>'
                    +'<div class="L_ZSS ZS2"><i class="fa fa-viadeo" aria-hidden="true"></i><span>生物多样性4</span></div>'
                    +'<div class="L_ZSS ZS3"><i class="fa fa-snowflake-o" aria-hidden="true"></i><span>自然保护区管理3</span></div>'
                    +'<div class="L_ZSS ZS4"><i class="fa fa-pie-chart" aria-hidden="true"></i><span>遥感监测管理2</span></div>'
                    +'<div class="L_ZSS ZS5"><i class="fa fa-share-alt" aria-hidden="true"></i><span>生态地面监测1</span></div>'
                    +'<div> </div>'
                    +'<div> </div>'
                    +'<div> </div>'
                    +'<div> </div>'
                    +'<div> </div>'
                    +'<div> </div>'
        $('.body .body-right .ZS-right').html(R_ZSCD);    
        $('.body .body-right .ZS-left').html(L_ZSCD); 
        $('.body .body-right .ZS-left').css('top','-'+$('.body .body-right .ZS-left').height()+'px');
        // 鼠标滑过右边子菜单
        for(var i=0; i<$(".body .body-right .ZS-right div.R_ZSS").length; i++){
            $(".body .body-right .ZS-right div.ZS"+i+"").click(function(){
                var div_top = $(this).offset().top;
                var div_position_top = $(this).position().top;
                var head_height = $('.head .test').height();
                var this_height = $(this).height();
                var right_this_top = $('.body .body-right .ZS-right').css("top");
                    right_this_top = right_this_top.split('px');
                    right_this_top = right_this_top[0];
                var left_this_top = $('.body .body-right .ZS-left').css("top");
                    left_this_top = left_this_top.split('px');
                    left_this_top = left_this_top[0];
                var YD = div_top-head_height+this_height-right_this_top;
                var divmarginTop = $('.body .body-right .ZS-right div').css('marginTop');
                    divmarginTop = divmarginTop.split('px');
                    divmarginTop = divmarginTop[0];
                $('.body .body-right .ZS-right').animate({top:'-'+YD+'px'},2000);
                // $('.body .body-right .ZS-left').animate({top:left_this_top-(-div_top)+'px'},2000);
                $('.body .body-right .ZS-left').animate({top:left_this_top-(-div_top)-divmarginTop*4+'px'},2000);
                $('.body .body-right .ZS-content .ZS-content-title').html($(this).html());
            }// ,function(){}
            );
        }
        // 鼠标滑过左边子菜单
         for(var i=0; i<$(".body .body-right .ZS-left div.L_ZSS").length; i++){
            $(".body .body-right .ZS-left div.ZS"+i+"").click(function(){
                var div_top = $(this).offset().top;
                var div_position_top = $(this).position().top;
                var head_height = $('.head .test').height();
                var this_height = $(this).height();
                var right_this_top = $('.body .body-right .ZS-right').css("top");
                    right_this_top = right_this_top.split('px');
                    right_this_top = right_this_top[0];
                var left_this_top = $('.body .body-right .ZS-left').css("top");
                    left_this_top = left_this_top.split('px');
                    left_this_top = left_this_top[0];
                var YD = div_top-head_height+this_height-right_this_top;
                var divmarginTop = $('.body .body-right .ZS-left div').css('marginTop');
                    divmarginTop = divmarginTop.split('px');
                    divmarginTop = divmarginTop[0];
                $('.body .body-right .ZS-left').animate({top:'-'+div_position_top-this_height+'px'},2000);
                $('.body .body-right .ZS-right').animate({top:right_this_top-(-div_top)-divmarginTop*4+'px'},2000);
                $('.body .body-right .ZS-content .ZS-content-title').html($(this).html());
            }// ,function(){}
            );
         }
         // 子系统鼠标经过
         $(".body .body-right .ZS div,.body .body-left .ZS div").hover(function(){
            $(this).css('border',"2px solid #fff");
         },function(){
            $(this).css('border',"");
         });
    });
    // nav
    $(function(){
        var bodywidth = $(".body .body-right").width();
        var dockwidth = $("#dock").width();
        $(".position").css('left',(bodywidth-dockwidth)/2+'px');
    });
    // page
    $(function(){
         // var bodywidth = $(".body .body-right").width();
         // var bodyheight = $(".body .body-right").height();
         // var pagewidth = $("body .body .body-right .PAGE").width();
         // var pageheight = $("body .body .body-right .PAGE").height();
        $("#STDMJC_PAGE").click(function(){
            $("body .body .body-right .PAGE").animate({width: "0%",height: "100%",left: '0%',top:'0%'},400).css("border-radius","0px 1000px 1000px 0px");
            setTimeout(function () {
                $("body .body .body-right .PAGE").animate({width: "0%",height: "100%",left: '0%',top:'0%'},400).css("border-radius","0px 0px 0px 0px");
                $(".STDMJC_PAGE").animate({width: "99.8%",height: "100%"},400).css("border-radius","0px 0px 0px 0px");
            }, 400);
        });   
        $("#YGJC_PAGE").click(function(){
            $("body .body .body-right .PAGE").animate({width: "0%",height: "0%",left: '0%',top:'0%'},800);
            setTimeout(function () {
                $(".YGJC_PAGE").animate({width: "99.8%",height: "100%",left: '0%',top:'0%'},800);
            }, 800);
        }); 
        $("#ZRBHQ_PAGE").click(function(){
            $("body .body .body-right .PAGE").animate({width: "0%",height: "0%",left: '50%',top:'50%'},800);
            setTimeout(function () {
                $(".ZRBHQ_PAGE").animate({width: "99.8%",height: "100%",left: '0px',top:'0px'}, 800);
                $("body .body .body-right .PAGE").animate({left: '0%',top:'0%'},800);
            },800);
        });
        $("#SWDYX_PAGE").click(function(){
            $("body .body .body-right .PAGE").css('transform','rotate(20deg)').animate({width: "0%",height: "0%",left: '100%',top:'100%'},800);
            setTimeout(function () {
                $(".SWDYX_PAGE").css('transform','rotate(20deg)').animate({width: "99.8%",height: "100%",left: '0%',top:'0%'},800);
            },800);
            setTimeout(function () {
                $(".SWDYX_PAGE").css('transform','rotate(0deg)');
                 $("body .body .body-right .PAGE").css('transform','rotate(0deg)');
            },1600);   
        });
        $("#XYKH_PAGE").click(function(){
            $("body .body .body-right .PAGE").animate({width: "0%",height: "0%",left: '100%',top:'100%'},800);
            setTimeout(function () {
                $(".XYKH_PAGE").animate({width: "99.8%",height: "100%",left: '0%',top:'0%'},800);
            }, 800);
        });
        $("#XYKH_STHX").click(function(){
            $("body .body .body-right .PAGE").animate({width: "0%",height: "0%",left: '50%',top:'50%'},800).css("border-radius","1000px 1000px 1000px 1000px");
            setTimeout(function () {
                $(".XYKH_STHX").animate({width: "99.8%",height: "100%",left: '0px',top:'0px'}, 800).css("border-radius","0px 0px 0px 0px");
                $("body .body .body-right .PAGE").animate({left: '0%',top:'0%'},800).css("border-radius","0px 0px 0px 0px");
            },800);
        });
         


    });
// });
    //子系统按钮点击事件
    $(function () {
        define.amd.jQuery = true; 
        require([
            'modules/bussystem'
        ], function (bussystem) {
            //do something with myModule
            $("#body-left img").bind('click', function () {
                bussystem.Selection_BusSystem($(this).attr("id"));
            });
        });
        
    })

// });